package com.justech.eat.service.impl;

import com.justech.eat.entity.User;
import com.justech.eat.repository.UserRepository;
import com.justech.eat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: eat-service
 * @description:
 * @author: feifei.li
 * @create: 2020-06-10 16:11
 **/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserRepository userRepository;

    @Override
    public List<User> getAll() {
        return userRepository.findAll();
    }

    @Override
    public void saveAll(List<User> users) {
        userRepository.saveAll(users);
    }

    /**
     * 受理员工离职
     *
     * @param jobNumber 工号
     */
    @Override
    public void acceptResignation(String jobNumber) {
        userRepository.deleteByJobNumber(jobNumber);
    }

    /**
     * 批量受理离职员工
     *
     * @param users
     * @return
     */
    @Override
    public int acceptResignation(List<User> users) {
        userRepository.deleteAll(users);
        return users.size();
    }
}
